commit 626de652455a6c061d5a045fb226212c1f7eaeb5
Author: Walter Doekes <walter+github@wjd.nu>
Date:   Fri Sep 18 09:56:40 2020 +0200

    Fix compatibility with older C++ in 3.6.x branch
    
    - no auto keyword (auto x = 1)
    - no range based loop (for (*iter) : iterable)
    - no std::to_string

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 111c137..f1f815a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -32,6 +32,7 @@ file(GLOB all_SRCS
   "${PROJECT_SOURCE_DIR}/src/*.c"
   )
 
+include(${CMAKE_ROOT}/Modules/CheckCXXSourceCompiles.cmake)
 include(${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
 include(${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
 include(${CMAKE_ROOT}/Modules/CheckStructHasMember.cmake)
@@ -43,6 +44,10 @@ CHECK_STRUCT_HAS_MEMBER("struct udphdr" uh_sport "sys/types.h;netinet/udp.h"  HA
 
 CHECK_SYMBOL_EXISTS(le16toh "endian.h" HAVE_DECL_LE16TOH)
 CHECK_SYMBOL_EXISTS(le16toh "sys/endian.h" HAVE_DECL_LE16TOH_BSD)
+CHECK_CXX_SOURCE_COMPILES("
+#include <string>
+int main() { std::to_string(1).c_str(); return 0; }
+" HAVE_STD_TOSTRING)
 
 configure_file("${PROJECT_SOURCE_DIR}/include/config.h.in"
                "${PROJECT_BINARY_DIR}/config.h" )
diff --git a/include/config.h.in b/include/config.h.in
index 8c22504..cf39ea1 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -1,5 +1,5 @@
 /*--------------------------------------------------------------------------
- * This file is autogenerated from config.h.in 
+ * This file is autogenerated from include/config.h.in
  * during the cmake configuration of your project. If you need to make changes
  * edit the original file NOT THIS FILE.
  * --------------------------------------------------------------------------*/
@@ -18,5 +18,6 @@
 #endif
 #cmakedefine HAVE_IP_COMPAT_H @HAVE_IP_COMPAT_H@
 #cmakedefine HAVE_UDP_UH_PREFIX @HAVE_UDP_UH_PREFIX@
+#cmakedefine HAVE_STD_TOSTRING @HAVE_STD_TOSTRING@
 
 #endif
diff --git a/include/screen.hpp b/include/screen.hpp
index 13a9708..37c8ddf 100644
--- a/include/screen.hpp
+++ b/include/screen.hpp
@@ -43,9 +43,12 @@ void print_statistics(int last);
 extern int key_backspace;
 extern int key_dc;
 
+typedef std::vector<std::string> string_array;
+
 class ScreenPrinter {
 public:
     ScreenPrinter():
+        M_last(false),
         M_headless(!isatty(fileno(stdout)))
     {};
     void redraw();
@@ -63,9 +66,9 @@ private:
     void draw_repartition_detailed(CStat::T_dynamicalRepartition * tabRepartition,
                                  int sizeOfTab);
 
-    std::vector<std::string> lines;
+    string_array lines;
 
-    bool M_last = false;
+    bool M_last;
 };
 
 extern ScreenPrinter* sp;
diff --git a/include/sipp.hpp b/include/sipp.hpp
index 878c99f..b04a619 100644
--- a/include/sipp.hpp
+++ b/include/sipp.hpp
@@ -83,6 +83,18 @@
 #include "ratetask.hpp"
 #include "watchdog.hpp"
 
+/* Backwards compatibility */
+#ifndef HAVE_STD_TOSTRING
+#include <sstream>
+namespace std {
+template <typename T> string to_string(T value) {
+    ostringstream os;
+    os << value;
+    return os.str();
+}
+}
+#endif
+
 /*
  * If this files is included in the Main, then extern definitions
  * are removed, and the DEFVAL macro becomes '= value;'. Else
diff --git a/src/screen.cpp b/src/screen.cpp
index bbf9cd2..5521a44 100644
--- a/src/screen.cpp
+++ b/src/screen.cpp
@@ -83,15 +83,15 @@ void print_statistics(int last)
 void ScreenPrinter::print_closing_stats() {
     M_last = true;
     get_lines();
-    for (auto line : lines) {
-        printf("%s\n", line.c_str());
+    for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+        printf("%s\n", (*it).c_str());
     }
 
     if (currentScreenToDisplay != DISPLAY_STAT_SCREEN) {
         currentScreenToDisplay = DISPLAY_STAT_SCREEN;
         get_lines();
-        for (auto line : lines) {
-            printf("%s\n", line.c_str());
+        for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+            printf("%s\n", (*it).c_str());
         }
     }
 
@@ -100,8 +100,8 @@ void ScreenPrinter::print_closing_stats() {
 void ScreenPrinter::print_to_file(FILE* f)
 {
     get_lines();
-    for (auto line : lines) {
-        fprintf(f, "%s\n", line.c_str());
+    for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+        fprintf(f, "%s\n", (*it).c_str());
     }
 }
 
@@ -114,8 +114,8 @@ void ScreenPrinter::redraw()
     if (!M_headless) {
         get_lines();
         erase();
-        for (auto line : lines) {
-            printw("%s\n", line.c_str());
+        for (string_array::iterator it = lines.begin(); it != lines.end(); ++it) {
+            printw("%s\n", (*it).c_str());
         }
 
         if (command_mode) {
